package org.bigjava.mapper;

import org.apache.ibatis.annotations.*;
import org.bigjava.bean.Wuye;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository("wuyeMapper")
public interface WuyeMapper {

    //根据负责人和查询业主
    @Select("select * from wuye where jsc=1 and realname like '%' #{realname} '%' and company like '%' #{company} '%'")
    public List<Wuye> wuYeMoHu(String realname,String company);

    //校验物业账号是否存在
    @Select("select * from wuye where jsc=1 and username=#{username}")
    public Wuye wuYeJiaoYan(String username);

    //根据id查出业主信息
    @Select("select * from wuye where id = #{id}")
    public Wuye wuYeId(int id);

    //根据id假删除业主
    @Update("update wuye set jsc=0 where id=#{id}")
    public int wuYeShanChu(int id);

    //物业总人数
    @Select("select count(*) from wuye where jsc=1")
    public int wuYeZong();

    //物业分页查询
    @Select("select * from wuye where jsc=1 limit #{offset},#{length}")
    public List<Wuye> wuYeFenYe(int offset , int length);

    //物业账号密码登录
    @Select("select * from wuye where username=#{username} and password=#{password}")
    public Wuye wuyeDengLu(String username,String password);

    //物业修改个人信息
    @Update("update wuye set username=#{username},password=#{password},phone=#{phone},realname=#{realname},company=#{company} where id=#{id}")
    public int wuYeXiuGai(Wuye wuye);

    //添加物业
    @Insert("insert into wuye(username,password,phone,realname,company)" +
            " values (#{username},#{password},#{phone},#{realname},#{company})")
    public int wuYeAdd(Wuye wuye);

    //查询全部物业
    @Select("select * from wuye where jsc=1")
    public List<Wuye> wuYeQuan();

}
